package com.kgc.basicprovider.controller;

import com.kgc.basic.pojo.GoodsCategory;
import com.kgc.basic.pojo.Store;
import com.kgc.basic.remote.GoodsCategoryRemote;
import com.kgc.basic.util.ResponseMsg;
import com.kgc.basicprovider.service.GoodsCategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class GoodsCategoryController implements GoodsCategoryRemote {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private GoodsCategoryService goodsCategoryService;

    @Override
    public ResponseMsg getGoodsCategoryList(@RequestBody Map<String, Object> paramMap) {
        logger.info("GoodsCategoryController getGoodsCategoryList paramMap:"+paramMap);
        ResponseMsg msg = goodsCategoryService.getGoodsCategoryList(paramMap);
        logger.debug("GoodsCategoryController getGoodsCategoryList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg getGoodsCategoryById(@RequestParam("id") Integer id) {
        logger.info("GoodsCategoryController getGoodsCategoryById id:"+id);
        ResponseMsg msg = goodsCategoryService.getGoodsCategoryById(id);
        logger.debug("GoodsCategoryController getGoodsCategoryById msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg getGoodsCategoryByName(@RequestParam("name") String name) {
        logger.info("GoodsCategoryController getGoodsCategoryByName name:"+name);
        ResponseMsg msg = goodsCategoryService.getGoodsCategoryByName(name);
        logger.debug("GoodsCategoryController getGoodsCategoryById msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg getGoodsCategoryByCode(String code) {
        logger.info("GoodsCategoryController getGoodsCategoryByCode code:"+code);
        ResponseMsg msg = goodsCategoryService.getGoodsCategoryCode(code);
        logger.debug("GoodsCategoryController getGoodsCategoryByCode msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg addGoodsCategory(@RequestBody GoodsCategory goodsCategory) {
        logger.info("GoodsCategoryController addGoodsCategory goodsCategory:"+goodsCategory);
        ResponseMsg msg = goodsCategoryService.addGoodsCategory(goodsCategory);
        logger.debug("GoodsCategoryController addGoodsCategory msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg modifyGoodsCategory(@RequestBody GoodsCategory goodsCategory) {
        logger.info("GoodsCategoryController modifyGoodsCategory goodsCategory:"+goodsCategory);
        ResponseMsg msg = goodsCategoryService.modifyGoodsCategory(goodsCategory);
        logger.debug("GoodsCategoryController modifyGoodsCategory msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delGoodsCategory(@RequestParam("id") Integer id) {
        logger.info("GoodsCategoryController delGoodsCategory id:"+id);
        ResponseMsg msg = goodsCategoryService.delGoodsCategory(id);
        logger.debug("GoodsCategoryController delGoodsCategory msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg showGoodsCategoryByTree() {
        logger.info("GoodsCategoryController showGoodsCategoryByTree is start..");
        ResponseMsg msg = goodsCategoryService.showGoodsCategoryByTree();
        logger.debug("GoodsCategoryController showGoodsCategoryByTree msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg getGoodsCategoryByParentId(Integer parentId) {
        logger.info("GoodsCategoryController getGoodsCategoryByParentId parentId:"+parentId);
        ResponseMsg msg = goodsCategoryService.getGoodsCategoryByParentId(parentId);
        logger.debug("GoodsCategoryController getGoodsCategoryByParentId msg:"+msg);
        return msg;
    }
}
